package cn.com.demo.keystore;

import chapter8.JCEKSStoreEntryExample;

import java.security.KeyStore;

public class JCEKSBuilderExample {

    /**
     * @param args
     */
    public static void main(String[] args) throws Exception {
        KeyStore store = JCEKSStoreEntryExample.createKeyStore();

        //create the builder
        KeyStore.Builder builder = KeyStore.Builder.newInstance(store,
                new KeyStore.PasswordProtection(JCEKSStoreEntryExample.keyPassword));

        //use the builder to recover the keystore and obtain the key
        store = builder.getKeyStore();

        KeyStore.ProtectionParameter param = builder.getProtectionParameter("end");
        KeyStore.Entry entry = store.getEntry("end", param);

        System.out.println("recovered " + entry.getClass());

    }

}
